package com.ks.comment.controller;


import com.ks.comment.controller.dto.CommentListRequest;
import com.ks.comment.service.IZpzAgreeService;
import com.ks.core.base._ControllerBase;
import com.ks.core.core.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 表结构公共字段 前端控制器
 * </p>
 *
 * @author kingdee123
 * @since 2020-12-18
 */
@RestController
@RequestMapping("/zpzAgree")
public class ZpzAgreeController extends _ControllerBase {

    @Autowired
    private IZpzAgreeService zpzAgreeService;

    @GetMapping("/queryAgreeStatus")
    @ApiOperation(value = "查询会员用户的赞/踩 状态", notes = "查询会员用户的赞/踩 状态")
    public Object queryAgreeStatus(@RequestParam int informationId, @RequestParam String type) {
        int i = zpzAgreeService.queryAgreeStatus(getContext(), informationId, type);
        return Result.success(i);
    }

    @GetMapping("/addAgree")
    @ApiOperation(value = "会员点赞，点踩接口", notes = "会员点赞，点踩接口")
    public Object addAgree(@RequestParam int informationId, @RequestParam String type, @RequestParam int status) {
        int i = zpzAgreeService.addAgree(getContext(), informationId, type, status);
        return Result.success(i);
    }

    @PostMapping("/getAgreeList")
    @ApiOperation(value = "请求信息的点赞/点踩记录清单", notes = "请求信息的点赞/点踩记录清单")
    public Object addJournal(@RequestBody CommentListRequest request) {
        Map<String, Object> agreeList = zpzAgreeService.getAgreeList(request.getInFormationId(), request.getType(), request.getPageNo(), request.getPageSize());
        return Result.success(agreeList);
    }

}

